<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,height=device-height,maximum-scale=1.0,user-scalable=no" />
    <title>Unity WebGL Player | %UNITY_WEB_NAME%</title>
    <style>
      * {
        border: 0;
        margin: 0;
        padding: 0;
      }
    </style>
    <script src="%UNITY_WEBGL_LOADER_URL%"></script>
    <script>
      var storage = {};
      function getStorageValue(key, defaultValue) {
        var v = storage[key];
        if (v === null) {
          return defaultValue;
        }
        if (typeof v !== 'undefined') {
          return v;
        }
        return defaultValue;
      }
      var WXWASMSDK = {
        WXInitializeSDK() {
          gameInstance.SendMessage('WXSDKManagerHandler', 'Inited', 200);
        },
        WXStorageSetIntSync(key, value) {
          storage[key] = value;
        },
        WXStorageGetIntSync(key, defaultValue) {
          return getStorageValue(key, defaultValue);
        },
        WXStorageSetFloatSync(key, value) {
          storage[key] = value;
        },
        WXStorageGetFloatSync(key, defaultValue) {
          return getStorageValue(key, defaultValue);
        },
        WXStorageSetStringSync(key, value) {
          storage[key] = value;
        },
        WXStorageGetStringSync(key, defaultValue) {
          return getStorageValue(key, defaultValue || '');
        },
        WXStorageDeleteAllSync() {
          storage = {};
        },
        WXStorageDeleteKeySync(key) {
          delete storage[key];
        },
        WXStorageHasKeySync(key) {
          return typeof storage[key] !== 'undefined';
        },
        WXCheckSession(s, f, c) {},
        WXAuthorize(scope, s, f, c) {},
        WXCreateUserInfoButton(x, y, width, height, lang, withCredentials) {
          return "";
        },
        WXUserInfoButtonShow(id) {},
        WXUserInfoButtonDestroy(id) {},
        WXUserInfoButtonHide(id) {},
        WXUserInfoButtonOffTap(id) {},
        WXUserInfoButtonOnTap(id) {},
        WXOnShareAppMessage(conf, isPromise) {},
        WXOnShareAppMessageResolve(conf) {},
        WXOffShareAppMessage() {},
        WXCreateBannerAd(conf) {
          return Math.random().toString(32);
        },
        WXCreateRewardedVideoAd(conf) {
          return Math.random().toString(32);
        },
        WXCreateInterstitialAd(conf) {
          return Math.random().toString(32);
        },
        WXCreateCustomAd(conf) {},
        WXADStyleChange(id, key, value) {},
        WXShowAd(id) {},
        WXHideAd(id) {},
        WXADGetStyleValue(id, key) {},
        WXADDestroy(id) {},
        WXADLoad(id, succ, fail) {},
        WXToTempFilePathSync(conf) {},
        WXGetUserDataPath() {},
        WXWriteFileSync(filePath, data, encoding) {},
        WXCreateFixedBottomMiddleBannerAd(adUnitId, adIntervals, height) {
          return Math.random().toString(32);
        },
        WXReportGameStart() {},
        WXReportGameSceneError(sceneId, errorType, errStr, extJsonStr) {},
        WXWriteLog(str) {},
        WXWriteWarn(str) {},
        WXHideLoadingPage() {},
        WXPreloadConcurrent() {},
        WXCreateInnerAudioContext() {
          return Math.random().toString(32);
        },
        WXInnerAudioContextSetBool() {},
        WXInnerAudioContextSetString() {},
        WXInnerAudioContextSetFloat() {},
        WXInnerAudioContextGetFloat() {},
        WXInnerAudioContextGetBool() {},
        WXInnerAudioContextPlay() {},
        WXInnerAudioContextPause() {},
        WXInnerAudioContextStop() {},
        WXInnerAudioContextDestroy() {},
        WXInnerAudioContextSeek() {},
        WXInnerAudioContextAddListener(id, key) {
          if (key === 'onCanplay') {
            setTimeout(function () {
              gameInstance.SendMessage(
                'WXSDKManagerHandler',
                'OnAudioCallback',
                JSON.stringify({
                  callbackId: id,
                  errMsg: key,
                })
              );
            }, 100);
          }
        },
        WXInnerAudioContextRemoveListener() {},
        WXPreDownloadAudios(paths, id) {
          gameInstance.SendMessage(
            'WXSDKManagerHandler',
            'WXPreDownloadAudiosCallback',
            JSON.stringify({
              callbackId: id.toString(),
              errMsg: '0',
            })
          );
        },
        WXCreateVideo() {
          return Math.random().toString(32);
        },
        WXVideoPlay() {},
        WXVideoAddListener() {},
        WXVideoDestroy() {},
        WXVideoExitFullScreen() {},
        WXVideoPause() {},
        WXVideoRequestFullScreen() {},
        WXVideoSeek() {},
        WXVideoStop() {},
        WXVideoRemoveListener() {},
        WXVideoSetProperty() {},
        WXShowOpenData() {},
        WXDownloadTexture(id, type, callback) {
          var Infos = {
            Texture: GameGlobal.TextureConfig,
            SpriteAtlas: GameGlobal.SpriteAtlasConfig,
          }[type];
          if (!Infos[id]) {
            return console.error(type + '映射id 不存在', id);
          }
          var path = Infos[id].p;
          var cid = type + '_' + id;
          if (downloadedTextures[cid]) {
            if (downloadedTextures[cid].data) {
              callback();
            } else {
              console.error(type + '映射id data 不存在！', id);
            }
          } else if (downloadingTextures[cid]) {
            downloadingTextures[cid].push(callback);
          } else {
            downloadingTextures[cid] = [callback];
            textureHandler.downloadFile(
              id,
              type,
              GameGlobal.AUDIO_PREFIX.replace(/\/$/, '') + '/' + path.replace(/\\/g, '/')
            );
          }
        },
        WXCreateGameClubButton() {
          return Math.random().toString(32);
        },
        WXGameClubButtonDestroy() {},
        WXGameClubButtonHide() {},
        WXGameClubButtonShow() {},
        WXGameClubButtonAddListener() {},
        WXGameClubButtonRemoveListener() {},
        WXGameClubButtonSetProperty() {},
        WXGameClubStyleChangeInt() {},
        WXGameClubStyleChangeStr() {},
        WXIsCloudTest() {
          return false;
        },
        WXUncaughtException() {},
        WXSetDataCDN() {},
        WXSetPreloadList() {},
        WXGetCachePath() {},
        WXGetPluginCachePath() {},
        WXGetFontRawData() {},
        WXShareFontBuffer() {},
        WXReportShareBehavior() {},
        WXShowAd2() {},
        WXToTempFilePath() {},
        WXDataContextPostMessage() {},
        WXHideOpenData() {},
        WXAccessFileSync() {},
        WXAccessFile() {},
        WXCopyFileSync() {},
        WXCopyFile() {},
        WXUnlinkSync() {},
        WXUnlink() {},
        WXReportUserBehaviorBranchAnalytics() {},
        WXWriteFile() {},
        WXWriteStringFile() {},
        WXAppendFile() {},
        WXAppendStringFile() {},
        WXWriteBinFileSync() {},
        WXReadFile() {},
        WXReadFileSync() {},
        WXLogManagerDebug() {},
        WXLogManagerInfo() {},
        WXLogManagerLog() {},
        WXLogManagerWarn() {},
        WXCleanAllFileCache() {},
        WXCleanFileCache() {},
        WXRemoveFile() {},
        WXOnLaunchProgress() {},
        WXMkdir() {},
        WXMkdirSync() {},
        WXRmdir() {},
        WXRmdirSync() {},
        WXCameraCreateCamera() {},
        WXCameraCloseFrameChange() {},
        WXCameraDestroy() {},
        WXCameraListenFrameChange() {},
        WXCameraOnAuthCancel() {},
        WXCameraOnCameraFrame() {},
        WXCameraOnStop() {},
        WX_GetRecorderManager() {},
        WX_OnRecorderError() {},
        WX_OnRecorderFrameRecorded() {},
        WX_OnRecorderInterruptionBegin() {},
        WX_OnRecorderInterruptionEnd() {},
        WX_OnRecorderPause() {},
        WX_OnRecorderResume() {},
        WX_OnRecorderStart() {},
        WX_OnRecorderStop() {},
        WX_RecorderPause() {},
        WX_RecorderResume() {},
        WX_RecorderStart() {},
        WX_RecorderStop() {},
        WX_UploadFile() {},
        WXUploadTaskAbort() {},
        WXUploadTaskOffHeadersReceived() {},
        WXUploadTaskOffProgressUpdate() {},
        WXUploadTaskOnHeadersReceived() {},
        WXUploadTaskOnProgressUpdate() {},
        WXStat() {},
        WX_GetGameRecorder() {},
        WX_GameRecorderOff() {},
        WX_GameRecorderOn() {},
        WX_GameRecorderStart() {},
        WX_GameRecorderAbort() {},
        WX_GameRecorderPause() {},
        WX_GameRecorderResume() {},
        WX_GameRecorderStop() {},
        WX_OperateGameRecorderVideo() {},
        WXChatCreate() {},
        WXChatHide() {},
        WXChatShow() {},
        WXChatClose() {},
        WXChatOpen() {},
        WXChatSetTabs() {},
        WXChatOn() {},
        WXChatOff() {},
        WXChatSetSignature() {},
        WXSetArrayBuffer() {},
        WX_FileSystemManagerReaddirSync() {},
        WX_FileSystemManagerReadCompressedFileSync() {},
        WX_FileSystemManagerClose() {},
        WX_FileSystemManagerFstat() {},
        WX_FileSystemManagerFtruncate() {},
        WX_FileSystemManagerGetFileInfo() {},
        WX_FileSystemManagerGetSavedFileList() {},
        WX_FileSystemManagerOpen() {},
        WX_FileSystemManagerRead() {},
        WX_FileSystemManagerReadCompressedFile() {},
        WX_FileSystemManagerReadZipEntry() {},
        WX_FileSystemManagerReaddir() {},
        WX_FileSystemManagerRemoveSavedFile() {},
        WX_FileSystemManagerRename() {},
        WX_FileSystemManagerRenameSync() {},
        WX_FileSystemManagerSaveFile() {},
        WX_FileSystemManagerTruncate() {},
        WX_FileSystemManagerUnzip() {},
        WX_FileSystemManagerWrite() {},
        WX_FileSystemManagerReadSync() {},
        WX_FileSystemManagerFstatSync() {},
        WX_FileSystemManagerStatSync() {},
        WX_FileSystemManagerWriteSync() {},
        WX_FileSystemManagerOpenSync() {},
        WX_FileSystemManagerSaveFileSync() {},
        WX_FileSystemManagerCloseSync() {},
        WX_FileSystemManagerFtruncateSync() {},
        WX_FileSystemManagerTruncateSync() {},
        WX_FileSystemManagerAppendFileSync() {},
        WX_FileSystemManagerAppendFileStringSync() {},
        WX_FileSystemManagerWriteStringSync() {},
        WX_FileSystemManagerReadZipEntryString() {},
        WX_FileSystemManagerWriteString() {},
        WX_OnNeedPrivacyAuthorization() {},
        WX_PrivacyAuthorizeResolve() {},
        WX_OnTouchCancel() {},
        WX_OffTouchCancel() {},
        WX_OnTouchEnd() {},
        WX_OffTouchEnd() {},
        WX_OnTouchMove() {},
        WX_OffTouchMove() {},
        WX_OnTouchStart() {},
        WX_OffTouchStart() {},
        WX_RegisterOnTouchCancelCallback() {},
        WX_RegisterOnTouchEndCallback() {},
        WX_RegisterOnTouchMoveCallback() {},
        WX_RegisterOnTouchStartCallback() {},
        WX_CreateTCPSocket() {},
        WX_TCPSocketBindWifi() {},
        WX_TCPSocketClose() {},
        WX_TCPSocketConnect() {},
        WX_TCPSocketWriteString() {},
        WX_TCPSocketWriteBuffer() {},
        WX_TCPSocketOffBindWifi() {},
        WX_TCPSocketOffClose() {},
        WX_TCPSocketOffConnect() {},
        WX_TCPSocketOffError() {},
        WX_TCPSocketOffMessage() {},
        WX_TCPSocketOnBindWifi() {},
        WX_TCPSocketOnClose() {},
        WX_TCPSocketOnConnect() {},
        WX_TCPSocketOnError() {},
        WX_TCPSocketOnMessage() {},
        WX_RegisterTCPSocketOnMessageCallback() {},
        WX_CreateUDPSocket() {},
        WX_UDPSocketClose() {},
        WX_UDPSocketConnect() {},
        WX_UDPSocketOffClose() {},
        WX_UDPSocketOffError() {},
        WX_UDPSocketOffListening() {},
        WX_UDPSocketOffMessage() {},
        WX_UDPSocketOnClose() {},
        WX_UDPSocketOnError() {},
        WX_UDPSocketOnListening() {},
        WX_UDPSocketOnMessage() {},
        WX_UDPSocketSendString() {},
        WX_UDPSocketSendBuffer() {},
        WX_UDPSocketSetTTL() {},
        WX_UDPSocketWriteString() {},
        WX_UDPSocketWriteBuffer() {},
        WX_UDPSocketBind() {},
        WX_RegisterUDPSocketOnMessageCallback() {},
        WX_OnBLECharacteristicValueChange() {},
        WX_OffBLECharacteristicValueChange() {},
        WX_RegisterOnBLECharacteristicValueChangeCallback() {},
        WX_StartGyroscope() {},
        WX_StopGyroscope() {},
        WX_OnGyroscopeChange() {},
        WX_OffGyroscopeChange() {},
        WX_RegisterStartGyroscopeCallback() {},
        WX_RegisterStopGyroscopeCallback() {},
        WX_RegisterOnGyroscopeChangeCallback() {},
        WX_CloudCloud() {},
        WX_CloudInit() {},
        WX_CloudCallFunction() {},
        WX_CloudCloudID() {},
        WX_CloudCallContainer() {},
        WX_CloudUploadFile() {},
        WX_CloudDownloadFile() {},
        WX_CloudGetTempFileURL() {},
        WX_CloudDeleteFile() {},
        WX_CloudCDN() {},
        WXLaunchOperaBridge() {},
        WX_SetPreferredFramesPerSecond() {},
        WX_OneWayFunction(functionName, successType, failType, completeType, conf, callbackId){},
        WX_OneWayNoFunction_v() {},
        WX_OneWayNoFunction_vs() {},
        WX_OneWayNoFunction_vt() {},
        WX_OneWayNoFunction_vst() {},
        WX_OneWayNoFunction_vsn() {},
        WX_OneWayNoFunction_vnns() {},
        WX_OnEventRegister() {},
        WX_OffEventRegister() {},
        WX_OnAddToFavorites() {},
        WX_OnAddToFavorites_Resolve(conf){},
        WX_OffAddToFavorites() {},
        WX_OnCopyUrl() {},
        WX_OnCopyUrl_Resolve(conf){},
        WX_OffCopyUrl() {},
        WX_OnHandoff() {},
        WX_OnHandoff_Resolve(conf){},
        WX_OffHandoff() {},
        WX_OnShareTimeline() {},
        WX_OnShareTimeline_Resolve(conf){},
        WX_OffShareTimeline() {},
        WX_OnGameLiveStateChange() {},
        WX_OnGameLiveStateChange_Resolve(conf){},
        WX_OffGameLiveStateChange() {},

        WX_SyncFunction_t() {
            return "";
        },
        WX_SyncFunction_tt() {
            return "";
        },
        WX_SyncFunction_bt() {
            return false;
        },
        WX_SyncFunction_nt() {
            return 0;
        },
        WX_SyncFunction_bs() {
            return false;
        },
        WX_SyncFunction_b() {
            return false;
        },
        WX_SyncFunction_bsnn() {
            return false;
        },
        WX_SyncFunction_ss() {
            return "";
        },
        WX_SyncFunction_tnn() {
            return "";
        },
        WX_ClassFunction() {return ""},
        WX_ClassOneWayFunction() {return ""},
        WX_ClassSetProperty() {},
        WX_ClassOneWayNoFunction_v() {},
        WX_ClassOneWayNoFunction_vs() {},
        WX_ClassOneWayNoFunction_t() {
            return "";
        },
        WX_ClassOneWayNoFunction_vt() {},
        WX_ClassOnEventFunction() {},
        WX_ClassOffEventFunction() {},      };
      var downloadedTextures = {};
      var downloadingTextures = {};
      var textureHandler = {
        downloadFile(textureId, type, prefix) {
          var url = prefix + '.png';
          var cid = type + '_' + textureId;
          var image = new Image();
          image.src = url;
          image.onload = function () {
            downloadedTextures[cid] = {
              data: image,
            };
            if (downloadingTextures[cid] instanceof Array) {
              downloadingTextures[cid].forEach(v => v());
            } else {
              downloadingTextures[cid]();
            }
            delete downloadingTextures[cid];
          };
          image.onerror = function () {
            console.error(url + ' 下载失败！');
          };
        },
      };

      var GameGlobal = {
        TextureConfig: {},
        SpriteAtlasConfig: {},
        DownloadedTextures: downloadedTextures,
        AUDIO_PREFIX: './Assets/Textures/',
      };
      window._ScaleRate = 1;
    </script>
    <script>
      var gameInstance = UnityLoader.instantiate('gameContainer', '%UNITY_WEBGL_BUILD_URL%');
    </script>
  </head>
  <body>
    <div id="gameContainer" style="width: 100%; height: 100%; margin: auto"></div>
    <script>
      document.addEventListener('DOMContentLoaded', () => {
        var div = document.getElementById('gameContainer');
        div.style.width = window.innerWidth + 'px';
        div.style.height = window.innerHeight + 'px';
        window.canvas = document.getElementsByTagName('canvas')[0];
      });
    </script>
  </body>
</html>
